//
//  DYAboutUsView.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/21.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYAboutUsView.h"

@interface DYAboutUsView ()

@property (nonatomic,strong)UIImageView *logoImageView;
@property (nonatomic,strong)DYAboutUsChildView *versionView;
@property (nonatomic,strong)DYAboutUsChildView *accountView;
@property (nonatomic,strong)UILabel *companyLabel;
@property (nonatomic,strong)UILabel *copyrightLabel;

@end

@implementation DYAboutUsView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.backgroundColor=WhiteColor;
    
    self.logoImageView =({
        UIImageView *imageView=[Utils imageViewWithImage:IMG(@"mine_guanyu")];
        imageView;
    });
    
    self.versionView = ({
        DYAboutUsChildView *view=[[DYAboutUsChildView alloc]init];
        view.titleLabel.text=@"版本号";
        view;
    });
    
    self.accountView = ({
        DYAboutUsChildView *view=[[DYAboutUsChildView alloc]init];
        view.titleLabel.text=@"微信公众号";
        view;
    });
    
    self.companyLabel = ({
        UILabel *label=[Utils labelWithTitle:@"重庆卡福  版权所有" titleFontSize:12 textColor:XHQHexColor(0x909090) backgroundColor:WhiteColor alignment:1];
        label;
    });
    
    self.copyrightLabel = ({
        UILabel *label=[Utils labelWithTitle:@"Copyright © 2018 Kafu.All rights reserved." titleFontSize:12 textColor:XHQHexColor(0x909090) backgroundColor:WhiteColor alignment:1];
        label;
    });
    
    
    [self addSubview:self.logoImageView];
    [self addSubview:self.versionView];
    [self addSubview:self.accountView];
    [self addSubview:self.companyLabel];
    [self addSubview:self.copyrightLabel];
    
    [self.logoImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(BILIHEIGHT(45));
        make.centerX.equalTo(self);
    }];
    
    [self.versionView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.right.equalTo(BILIWIDTH(-10));
        make.top.equalTo(self.logoImageView.bottom).offset(BILIHEIGHT(30));
        make.height.equalTo(BILIHEIGHT(58));
    }];
    
    [self.accountView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.versionView.bottom);
        make.left.right.height.equalTo(self.versionView);
    }];
    
    [self.copyrightLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(BILIHEIGHT(-20));
        make.centerX.equalTo(self);
    }];
    
    [self.companyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.copyrightLabel.top).offset(BILIHEIGHT(-5));
        make.centerX.equalTo(self);
    }];
    
    
    self.versionView.contentLabel.text=[NSString stringWithFormat:@"V %@ 版本",[[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]];
    self.accountView.contentLabel.text=@"kafuzhinengguanjia";
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end


@implementation DYAboutUsChildView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.titleLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:12 textColor:[UIColor xhq_content] alignment:0];
        label;
    });
    
    self.contentLabel=({
        UILabel *label=[Utils labelWithTitleFontSize:14 textColor:[UIColor xhq_aTitle] alignment:0];
        label;
    });
    
    self.line = ({
        UILabel *line=[UILabel xhq_lineLabel];
        line;
    });
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.contentLabel];
    [self addSubview:self.line];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(0));
        make.top.equalTo(BILIHEIGHT(10));
    }];
    
    [self.contentLabel makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(BILIHEIGHT(-1));
        make.height.equalTo(BILIHEIGHT(30));
        make.left.equalTo(BILIWIDTH(0));
        make.right.equalTo(BILIWIDTH(0));
    }];
    
    [self.line makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.left.right.equalTo(self.contentLabel);
        make.height.equalTo(BILIWIDTH(0.7));
    }];
    
}
@end
